<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <!-- v-on指令一般用于绑定方法 -->

    <!-- v-on指令可以将v-on:click 简写为@click -->

    <div id="app">
        <p>
            {{message}}
        </p>
        <button @click="reverseMessage">反转</button>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el:'#app',
            data () {
                return {
                    message:'my name is cpw'
                }
            },
            methods: {
                reverseMessage(){
                    this.message = this.message.split('').reverse().join('')
                }
            }
        })
    </script>
</body>
</html>